﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BookExchange.Business;
using BookExchange.CustomClass.Base;
using BookExchange.ODataService;
using BookExchange.Configuration;

namespace BookExchange
{
    public partial class MemberInfo : BasePage
    {
        MemberBusiness memberBus;

        public MemberInfo()
            : base()
        {
            this.memberBus = new MemberBusiness();
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            //Get current member
            var memberCode = 0;
            if (!int.TryParse(Request.QueryString["c"], out memberCode))
            {
                RedirectToErrorPage();
                return;
            }

            var member = memberBus.GetMemberByCode(memberCode);

            //Bind to GUI
            BindData(member);
        }

        private void BindData(Member member)
        {
            if (member == null)
            {
                areaMemberInfo.Visible = false;
                return;
            }

            //display form
            areaMemberInfo.Visible = true;
            txtDisplayName.Text = member.DisplayName;
            txtFullName.Text = member.DisplayName;
            txtBirthday.Text = DateTime.Now.ToString(AppConfiguration.Instance.DateFormat);
            txtCreateDate.Text = GetDate(member.CreatingDate);

        }
    }
}